package com.ruoyi.system.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LabInstrumentationForeignService;
import com.ruoyi.system.service.ILabInstrumentationForeignServiceService;

/**
 * 仪器对外服务Controller
 * 
 * @author lzlong
 * @date 2022-04-29
 */
@RestController
@RequestMapping("/system/instrumentationForeignService")
public class LabInstrumentationForeignServiceController extends BaseController {
	@Autowired
	private ILabInstrumentationForeignServiceService labInstrumentationForeignServiceService;

	/**
	 * 查询仪器对外服务列表
	 */
	@PreAuthorize("@ss.hasPermi('system:instrumentationForeignService:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabInstrumentationForeignService labInstrumentationForeignService) {
		startPage();
		List<LabInstrumentationForeignService> list = labInstrumentationForeignServiceService
				.selectLabInstrumentationForeignServiceList(labInstrumentationForeignService);
		return getDataTable(list);
	}

	/**
	 * 导出仪器对外服务列表
	 */
	/*
	 * @PreAuthorize(
	 * "@ss.hasPermi('system:instrumentationForeignService:export')")
	 * 
	 * @Log(title = "仪器对外服务", businessType = BusinessType.EXPORT)
	 * 
	 * @GetMapping("/export") public AjaxResult
	 * export(LabInstrumentationForeignService labInstrumentationForeignService)
	 * { List<LabInstrumentationForeignService> list =
	 * labInstrumentationForeignServiceService.
	 * selectLabInstrumentationForeignServiceList(
	 * labInstrumentationForeignService);
	 * ExcelUtil<LabInstrumentationForeignService> util = new
	 * ExcelUtil<LabInstrumentationForeignService>(
	 * LabInstrumentationForeignService.class); return util.exportExcel(list,
	 * "instrumentationForeignService"); }
	 */

	/**
	 * 获取仪器对外服务详细信息
	 */
	@PreAuthorize("@ss.hasPermi('system:instrumentationForeignService:query')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return AjaxResult
				.success(labInstrumentationForeignServiceService.selectLabInstrumentationForeignServiceById(id));
	}

	/**
	 * 新增仪器对外服务
	 */
	@PreAuthorize("@ss.hasPermi('system:instrumentationForeignService:edit')")
	@Log(title = "仪器对外服务", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabInstrumentationForeignService labInstrumentationForeignService) {
		return toAjax(labInstrumentationForeignServiceService
				.insertLabInstrumentationForeignService(labInstrumentationForeignService));
	}

	/**
	 * 修改仪器对外服务
	 */
	@PreAuthorize("@ss.hasPermi('system:instrumentationForeignService:edit')")
	@Log(title = "仪器对外服务", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabInstrumentationForeignService labInstrumentationForeignService) {
		return toAjax(labInstrumentationForeignServiceService
				.updateLabInstrumentationForeignService(labInstrumentationForeignService));
	}

	/**
	 * 删除仪器对外服务
	 */
	@PreAuthorize("@ss.hasPermi('system:instrumentationForeignService:edit')")
	@Log(title = "仪器对外服务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable Long[] ids) {
		return toAjax(labInstrumentationForeignServiceService.deleteLabInstrumentationForeignServiceByIds(ids));
	}
}
